package com.bingbing.back.service.Impl;

import com.bingbing.back.dto.SchoolAdmScoreDto;
import com.bingbing.back.mapper.SchoolAdmScoreMapper;
import com.bingbing.back.po.SchoolAdmScore;
import com.bingbing.back.service.SchoolAdmScoreService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SchoolAdmScoreServiceImpl implements SchoolAdmScoreService {
    @Resource
    private SchoolAdmScoreMapper schoolAdmScoreMapper;

    @Override
    public List<String> searchAdmScoreBatchByYear(int admYear) {
        return schoolAdmScoreMapper.searchAdmScoreBatchByYear(admYear);
    }

    @Override
    public List<SchoolAdmScoreDto> searchAdmScore(SchoolAdmScore schoolAdmScore) {
        List<SchoolAdmScoreDto> list = schoolAdmScoreMapper.searchAdmScore(schoolAdmScore);
        list.forEach(s->{
            String str = "";
            if(s.getSchoolLoScore() == null) str += "-";
            else str += s.getSchoolLoScore().toString();
            str += "/";
            if(s.getSchoolLoRank() == null) str += "-";
            else str += s.getSchoolLoRank().toString();
            s.setScoreAndRank(str);
        });
        return list;
    }
}
